package com.ys.erp.framework.exception;


import com.ys.erp.framework.response.ResponseDTO;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * @author lwj
 * @date 2021/5/1
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class YsException extends RuntimeException {

    /**
     * 状态码
     */
    protected int code;

    /**
     * 错误消息
     */
    protected String message;

    /**
     * 自定义错误码与错误信息
     *
     * @param code 状态码
     * @param message 异常消息
     */
    public YsException(int code, String message) {
        super(message);
        this.message = message;
        this.code = code;
    }

    /**
     * 枚举定义错误码错误信息
     *
     * @param responseDTO responseCodeDTO
     *
     */
    public YsException(ResponseDTO<?> responseDTO) {
        super(responseDTO.getMessage());
        this.code = responseDTO.getCode();
        this.message = responseDTO.getMessage();
    }

}
